import axios from './axios'
import qs from 'qs'

import {appUrl} from '@/config/config'
// 验证是否存在班费管理人员及账号设置
export const chekClassFareAccountManageList = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: appUrl + '/school/api/home/classFareAccountManage/chekClassFareAccountManageList/' + params.schoolId,
            method: 'post',
            data: params
        }).then(res => {
            resolve(res.data)
        }).catch(error => {
            reject(error)
        })
    })
}
// 获取班费余额 和 班费设置
export const getStatistics = (params) => {
    return new Promise((resolve,reject) => {
        axios({
            url: appUrl + '/school/api/home/classFareAccountManage',
            method: 'get',
            params
        }).then(res => {
            resolve(res.data)
        })
    })
}
// 班费收款记录 列表
export const recordCollectionClassFare = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: appUrl + '/school/api/home/recordCollectionClassFare',
            method: 'get',
            params
        }).then(res => {
            resolve(res.data)
        }).catch(error => {
            reject(error)
        })
    })
}
// 班费交纳提取记录 列表
export const recordCashClassFare = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: appUrl + '/school/api/home/recordCashClassFare',
            method: 'get',
            params
        }).then(res => {
            resolve(res.data)
        }).catch(error => {
            reject(error)
        })
    })
}
// 收取班费
export const collectionClassFare = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: appUrl + '/school/api/home/recordCollectionClassFare',
            method: 'post',
            data: params
        }).then(res => {
            resolve(res.data)
        }).catch(error => {
            reject(error)
        })
    })
}
// 修改账户设置
export const putClassFareAccountManage = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: appUrl + '/school/api/home/classFareAccountManage/account',
            method: 'put',
            data: params
        }).then(res => {
            resolve(res.data)
        }).catch(error => {
            reject(error)
        })
    })
}
// 提取班费
export const cashCurrency = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: appUrl + '/school/api/home/recordCashClassFare/cashCurrency',
            method: 'post',
            data: params
        }).then(res => {
            resolve(res.data)
        }).catch(error => {
            reject(error)
        })
    })
}
// 获取班费缴纳记录 待交班费列表
export const recordStudentClassFare = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: appUrl + '/school/api/home/recordStudentClassFare',
            method: 'get',
            params
        }).then(res => {
            resolve(res.data)
        }).catch(error => {
            reject(error)
        })
    })
}
// 班费催缴
export const sendWeChatMsgForSingle = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: appUrl + '/school/api/home/recordStudentClassFare/'+ params.id +'/sendWeChatMsgForSingle',
            method: 'post',
            data: params
        }).then(res => {
            resolve(res.data)
        }).catch(error => {
            reject(error)
        })
    })
}
// 家长端=============================================================================
// 设置已读
export const readRecordStudentClassFare = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: appUrl + '/school/api/home/recordStudentClassFare/readRecordStudentClassFare',
            method: 'post',
            data: params
        }).then(res => {
            resolve(res.data)
        }).catch(error => {
            reject(error)
        })
    })
}
// 支付班费
export const pay = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: appUrl + '/school/api/home/recordStudentClassFare/pay',
            method: 'post',
            data: params
        }).then(res => {
            resolve(res.data)
        }).catch(error => {
            reject(error)
        })
    })
}
// 刷新订单状态
export const refreshPayState = (params) => {
    return new Promise((resolve, reject) => {
        axios({
            url: appUrl + '/school/api/home/recordStudentClassFare/refreshPayState',
            method: 'post',
            data: params
        }).then(res => {
            resolve(res.data)
        }).catch(error => {
            reject(error)
        })
    })
}

